package
{
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.ui.Keyboard;
	
	public class CGameState_Explain extends CGameState
	{
		public function CGameState_Explain(refGame:CGame)
		{
			super(refGame);
			
			cMovieClip = new CMC_GameState_Explain();
		}
		override public function EnterState() :void
		{
			cMovieClip.stage.addEventListener(KeyboardEvent.KEY_DOWN, OnKeyDown);
			CMC_GameState_Explain(cMovieClip).btnNext.addEventListener(MouseEvent.CLICK, OnClick_Next);
		}
		override public function LeaveState() :void
		{
			cMovieClip.stage.removeEventListener(KeyboardEvent.KEY_DOWN, OnKeyDown);
			CMC_GameState_Explain(cMovieClip).btnNext.removeEventListener(MouseEvent.CLICK, OnClick_Next);
		}
		
		private function ProcessStartGame() :void
		{
			m_refGame.EnterState(CGameState.GAME_STATE_PLAY);
			
			CSoundManager.instance.PlaySound(CSoundManager.SOUND_4_START);
			CSoundManager.instance.StopSound(CSoundManager.SOUND_1_TITLE);
			CSoundManager.instance.PlaySound(CSoundManager.SOUND_2_GAME, int.MAX_VALUE);
		}
		
		private function OnClick_Next(event :MouseEvent) :void
		{
			ProcessStartGame();
		}
		private function OnKeyDown(event :KeyboardEvent) :void
		{
			if (event.keyCode == Keyboard.ENTER)
			{
				ProcessStartGame();
			}
		}
		
	}
}